package Operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2021-09-21
 * Time:21:06
 */
public class BorrowOperation implements IOperation{

    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要借阅图书的名字");
        String name = scanner.nextLine();
        int size = bookList.getBookSize();
        for (int i = 0; i < size; i++) {
            Book book = bookList.getBook(i);


            if (book.getName().equals(name)){
                book.setState(true);
                System.out.println("借阅成功");
                return;
            }
        }
        System.out.println("没有该书籍");
    }
}
